package sybl.wb.com.demo;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;

import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;

import org.json.JSONObject;

/**
 * activity FragmentActivity ActionBarActivity AppcomentActivity
 * 简介  : Volley是谷歌2013I/O大会上推出的一套解决移动端与服务器通信的框架
 * 主要功能
 * 1> json数据加载,图片异步下载
 * 2> 缓存功能
 * 3> 跟Activity的生命周期联动
 * 4> 网络请求排序
 * 重要类
 * Volley
 * 加载数据Request
 * 1>StringRequest
 * 2>JsonRequest
 * 2.1>JsonObjectRequest
 * 2.2>JsonArrayRequest
 * 3>ImageRequest
 * 图片异步下载功能
 * ImageLoader
 * NetworkImageView
 */
public class MainActivity extends AppCompatActivity {

    private String url = "http://www.0790tg.com/appapi/api.php?s=/Tuan/typeList&type=1";
    private RequestQueue queue;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        stringRequestMethod();
    }

    private void stringRequestMethod() {
        queue = Volley.newRequestQueue(this);



        StringRequest request = new StringRequest(url, new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                Log.i("resoponse",response);

            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {

            }
        });
        request.setTag(this);
        request.setShouldCache(false);
        queue.add(request);
    }
    private void JsonObjectRequestMethod() {
        queue = Volley.newRequestQueue(this);

    }

}
